package lab02.Triangle;

/**
 * Created by lenovo on 2017/10/14.
 */
public class Triangele {
    //属性
    private double a;
    private double b;
    private double c;
    private double area;
    private double perimeter;
    private boolean isTriangele;


    //行为
    public Triangele(double a, double b, double c) {
        this.setA(a);
        this.setB(b);
        this.setC(c);
        this.setTriangele(trangle());

    }

    private boolean trangle() {
        if ((a + b > c) && (a + c > b) && (b + c > a) && (a - b < c) && (a - c < b) && (b - c < a))
            return true;
        return false;

    }


    public double getArea() {
        if (isTriangele) {
            double m = (a + b + c) / 2;
            double area= Math.sqrt(m * (m - a) * (m - b) * (m - c));
            return area;
        }else {
            System.out.println("不是三角形不能输出，请从新修改三边");
        }
        return area;
    }
    public double getPerimeter(){
        if (isTriangele){
            double perimeter=a+b+c;
            return perimeter;
        }else {
            System.out.println("不是三角形不能输出，请从新修改三边");
        }
        return perimeter;

    }
    public String toDo(){
        return "边a:"+this.getA()+"\n"+
                "边b:"+this.getB()+"\n"+
                "边c:"+this.getC()+"\n"+
                this.isTriangele;
    }






    //函数

    public double getA() {
        return a;
    }

    public void setA(double a) {
        this.a = a;
    }

    public double getB() {
        return b;
    }

    public void setB(double b) {
        this.b = b;
    }

    public double getC() {
        return c;
    }

    public void setC(double c) {
        this.c = c;
    }

    public boolean isTriangele() {
        return isTriangele;
    }

    public void setTriangele(boolean triangele) {
        isTriangele = triangele;
    }
}
